home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / Label3DBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  14KB  |  375 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  09/07/97    LAB    Fixed misspelling of descriptions.
  8. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  9.  
  10. /**
  11.  * BeanInfo for Label3D.
  12.  *
  13.  */
  14. public class Label3DBeanInfo extends SimpleBeanInfo {
  15.  
  16.     /**
  17.      * Constructs a Label3DBeanInfo object.
  18.      */
  19.     public Label3DBeanInfo() {
  20.     }
  21.  
  22.     /**
  23.      * Gets a BeanInfo for the superclass of this bean.
  24.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  25.      */
  26.     public BeanInfo[] getAdditionalBeanInfo() {
  27.         try {
  28.             BeanInfo[] bi = new BeanInfo[1];
  29.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  30.             return bi;
  31.         }
  32.         catch (IntrospectionException e) { throw new Error(e.toString());}
  33.     }
  34.  
  35.     /**
  36.      * Gets the SymantecBeanDescriptor for this bean.
  37.      * @return an object of type SymantecBeanDescriptor
  38.      * @see symantec.itools.beans.SymantecBeanDescriptor
  39.      */
  40.     public BeanDescriptor getBeanDescriptor() {
  41.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  42.         String s=group.getString("GroupAWTAdditions"); 
  43.  
  44.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  45.         bd.setFolder(s);
  46.         bd.setToolbar(s);
  47.         bd.setWinHelp("0x123AD");
  48.  
  49.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  50.         s=conn.getString("INDENT_ZERO"); 
  51.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  52.                                                 "%name%.INDENT_ZERO",s));
  53.  
  54.         s=conn.getString("INDENT_ONE"); 
  55.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  56.                                                 "%name%.INDENT_ONE",s));
  57.  
  58.         s=conn.getString("INDENT_TWO"); 
  59.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  60.                                                 "%name%.INDENT_TWO",s));
  61.  
  62.         s=conn.getString("ALIGN_LEFT"); 
  63.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  64.                                                 "%name%.ALIGN_LEFT",s));
  65.  
  66.         s=conn.getString("ALIGN_CENTERED"); 
  67.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  68.                                                 "%name%.ALIGN_CENTERED",s));
  69.  
  70.         s=conn.getString("ALIGN_RIGHT"); 
  71.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  72.                                                 "%name%.ALIGN_RIGHT",s));
  73.  
  74.         s=conn.getString("BEVEL_LOWERED"); 
  75.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  76.                                                 "%name%.BEVEL_LOWERED",s));
  77.  
  78.         s=conn.getString("BEVEL_RAISED"); 
  79.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  80.                                                 "%name%.BEVEL_RAISED",s));
  81.  
  82.         s=conn.getString("BEVEL_LINE"); 
  83.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  84.                                                 "%name%.BEVEL_LINE",s));
  85.  
  86.         s=conn.getString("BEVEL_NONE"); 
  87.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  88.                                                 "%name%.BEVEL_NONE",s));
  89.  
  90.  
  91.         return (BeanDescriptor) bd;
  92.     }
  93.  
  94.     /**
  95.      * Gets an image that may be used to visually represent this bean
  96.      * (in the toolbar, on a form, etc).
  97.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  98.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  99.      * @return an image for this bean, always color even if requested monochrome
  100.      * @see BeanInfo#ICON_MONO_16x16
  101.      * @see BeanInfo#ICON_COLOR_16x16
  102.      * @see BeanInfo#ICON_MONO_32x32
  103.      * @see BeanInfo#ICON_COLOR_32x32
  104.      */
  105.     public java.awt.Image getIcon(int iconKind) {
  106.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  107.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  108.             java.awt.Image img = loadImage("Label3DC16.gif");
  109.             return img;
  110.         }
  111.  
  112.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  113.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  114.             java.awt.Image img = loadImage("Label3DC32.gif");
  115.             return img;
  116.         }
  117.  
  118.         return null;
  119.     }
  120.  
  121.     /**
  122.      * Gets an array of descriptions of the methods used for "connections" by
  123.      * Visual CafΘ's Interaction Wizard.
  124.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  125.      * @return method descriptions for this bean
  126.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  127.      */
  128.     public MethodDescriptor[] getMethodDescriptors() {
  129.         Class[] args;
  130.         ConnectionDescriptor connection;
  131.         java.util.Vector connections;
  132.         java.util.Vector md = new java.util.Vector();
  133.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  134.  
  135.         try{
  136.             args = null;
  137.             MethodDescriptor getBevelStyle = new MethodDescriptor(beanClass.getMethod("getBevelStyle", args));
  138.  
  139.             connections = new java.util.Vector();
  140.             connection = new ConnectionDescriptor("output", "int", "",
  141.                                     "%name%.getBevelStyle()",
  142.                                     conn.getString("getBevelStyleLabel"));
  143.             connections.addElement(connection);
  144.  
  145.             getBevelStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  146.             md.addElement(getBevelStyle);
  147.         } catch (Exception e) { throw new Error("getBevelStyle:: " + e.toString()); }
  148.  
  149.         try{
  150.             args = null;
  151.             MethodDescriptor getBorderIndent = new MethodDescriptor(beanClass.getMethod("getBorderIndent", args));
  152.  
  153.             connections = new java.util.Vector();
  154.             connection = new ConnectionDescriptor("output", "int", "",
  155.                                     "%name%.getBorderIndent()",
  156.                                     conn.getString("getBorderIndent"));
  157.             connections.addElement(connection);
  158.  
  159.             getBorderIndent.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  160.             md.addElement(getBorderIndent);
  161.         } catch (Exception e) { throw new Error("getBorderIndent:: " + e.toString()); }
  162.  
  163.         try{
  164.             args = new Class[1];
  165.             args[0] = java.lang.String.class ;
  166.             MethodDescriptor setText = new MethodDescriptor(beanClass.getMethod("setText", args));
  167.  
  168.             connections = new java.util.Vector();
  169.             connection = new ConnectionDescriptor("input", "String", "",
  170.                                     "%name%.setText(%arg%);",
  171.                                     conn.getString("setText"));
  172.             connections.addElement(connection);
  173.  
  174.             setText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  175.             md.addElement(setText);
  176.         } catch (Exception e) { throw new Error("setText:: " + e.toString()); }
  177.  
  178.         try{
  179.             args = null;
  180.             MethodDescriptor getBorderedColor = new MethodDescriptor(beanClass.getMethod("getBorderedColor", args));
  181.  
  182.             connections = new java.util.Vector();
  183.             connection = new ConnectionDescriptor("output", "Color", "",
  184.                                     "%name%.getBorderedColor()",
  185.                                     conn.getString("getBorderedColor"));
  186.             connections.addElement(connection);
  187.  
  188.             getBorderedColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  189.             md.addElement(getBorderedColor);
  190.         } catch (Exception e) { throw new Error("getBorderedColor:: " + e.toString()); }
  191.  
  192.         try{
  193.             args = new Class[1];
  194.             args[0] = java.awt.Color.class ;
  195.             MethodDescriptor setTextColor = new MethodDescriptor(beanClass.getMethod("setTextColor", args));
  196.  
  197.             connections = new java.util.Vector();
  198.             connection = new ConnectionDescriptor("input", "Color", "",
  199.                                     "%name%.setTextColor(%arg%);",
  200.                                     conn.getString("setTextColor"));
  201.             connections.addElement(connection);
  202.  
  203.             setTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  204.             md.addElement(setTextColor);
  205.         } catch (Exception e) { throw new Error("setTextColor:: " + e.toString()); }
  206.  
  207.         try{
  208.             args = new Class[1];
  209.             args[0] = java.lang.Integer.TYPE ;
  210.             MethodDescriptor setAlignStyle = new MethodDescriptor(beanClass.getMethod("setAlignStyle", args));
  211.  
  212.             connections = new java.util.Vector();
  213.             connection = new ConnectionDescriptor("input", "int", "",
  214.                                     "%name%.setAlignStyle(%arg%);",
  215.                                     conn.getString("setAlignStyleLabel"));
  216.             connections.addElement(connection);
  217.  
  218.             setAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  219.             md.addElement(setAlignStyle);
  220.         } catch (Exception e) { throw new Error("setAlignStyle:: " + e.toString()); }
  221.  
  222.         try{
  223.             args = null;
  224.             MethodDescriptor getTextColor = new MethodDescriptor(beanClass.getMethod("getTextColor", args));
  225.  
  226.             connections = new java.util.Vector();
  227.             connection = new ConnectionDescriptor("output", "Color", "",
  228.                                     "%name%.getTextColor()",
  229.                                     conn.getString("getTextColorLabel"));
  230.             connections.addElement(connection);
  231.  
  232.             getTextColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  233.             md.addElement(getTextColor);
  234.         } catch (Exception e) { throw new Error("getTextColor:: " + e.toString()); }
  235.  
  236.         try{
  237.             args = new Class[1];
  238.             args[0] = java.lang.Integer.TYPE ;
  239.             MethodDescriptor setBevelStyle = new MethodDescriptor(beanClass.getMethod("setBevelStyle", args));
  240.  
  241.             connections = new java.util.Vector();
  242.             connection = new ConnectionDescriptor("input", "int", "",
  243.                                     "%name%.setBevelStyle(%arg%);",
  244.                                     conn.getString("setBevelStyleLabel"));
  245.             connections.addElement(connection);
  246.  
  247.             setBevelStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  248.             md.addElement(setBevelStyle);
  249.         } catch (Exception e) { throw new Error("setBevelStyle:: " + e.toString()); }
  250.  
  251.         try{
  252.             args = null;
  253.             MethodDescriptor getText = new MethodDescriptor(beanClass.getMethod("getText", args));
  254.  
  255.             connections = new java.util.Vector();
  256.             connection = new ConnectionDescriptor("output", "String", "",
  257.                                     "%name%.getText()",
  258.                                     conn.getString("getText"));
  259.             connections.addElement(connection);
  260.  
  261.             getText.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  262.             md.addElement(getText);
  263.         } catch (Exception e) { throw new Error("getText:: " + e.toString()); }
  264.  
  265.         try{
  266.             args = new Class[1];
  267.             args[0] = java.awt.Color.class ;
  268.             MethodDescriptor setBorderedColor = new MethodDescriptor(beanClass.getMethod("setBorderedColor", args));
  269.  
  270.             connections = new java.util.Vector();
  271.             connection = new ConnectionDescriptor("input", "Color", "",
  272.                                     "%name%.setBorderedColor(%arg%);",
  273.                                     conn.getString("setBorderedColor"));
  274.             connections.addElement(connection);
  275.  
  276.             setBorderedColor.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  277.             md.addElement(setBorderedColor);
  278.         } catch (Exception e) { throw new Error("setBorderedColor:: " + e.toString()); }
  279.  
  280.         try{
  281.             args = new Class[1];
  282.             args[0] = java.lang.Integer.TYPE ;
  283.             MethodDescriptor setBorderIndent = new MethodDescriptor(beanClass.getMethod("setBorderIndent", args));
  284.  
  285.             connections = new java.util.Vector();
  286.             connection = new ConnectionDescriptor("input", "int", "",
  287.                                     "%name%.setBorderIndent(%arg%);",
  288.                                     conn.getString("setBorderIndent"));
  289.             connections.addElement(connection);
  290.  
  291.             setBorderIndent.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  292.             md.addElement(setBorderIndent);
  293.         } catch (Exception e) { throw new Error("setBorderIndent:: " + e.toString()); }
  294.  
  295.         try{
  296.             args = null;
  297.             MethodDescriptor getAlignStyle = new MethodDescriptor(beanClass.getMethod("getAlignStyle", args));
  298.  
  299.             connections = new java.util.Vector();
  300.             connection = new ConnectionDescriptor("output", "int", "",
  301.                                     "%name%.getAlignStyle()",
  302.                                     conn.getString("getAlignStyle"));
  303.             connections.addElement(connection);
  304.  
  305.             getAlignStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  306.             md.addElement(getAlignStyle);
  307.         } catch (Exception e) { throw new Error("getAlignStyle:: " + e.toString()); }
  308.  
  309.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  310.         md.copyInto(rv);
  311.  
  312.         return rv;
  313.     }
  314.  
  315.     /**
  316.      * Returns descriptions of this bean's properties.
  317.      */
  318.     public PropertyDescriptor[] getPropertyDescriptors() {
  319.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  320.  
  321.         try{
  322.         PropertyDescriptor defProperty = new PropertyDescriptor("text", beanClass);
  323.         defProperty.setBound(true);
  324.         defProperty.setConstrained(true);
  325.         defProperty.setDisplayName(prop.getString("text"));
  326.  
  327.         PropertyDescriptor alignStyle = new PropertyDescriptor("alignStyle", beanClass);
  328.         alignStyle.setBound(true);
  329.         alignStyle.setConstrained(true);
  330.         alignStyle.setDisplayName(prop.getString("alignStyle"));
  331.         alignStyle.setValue("ENUMERATION", "ALIGN_LEFT=0, ALIGN_CENTERED=1, ALIGN_RIGHT=2");
  332.  
  333.         PropertyDescriptor bevelStyle = new PropertyDescriptor("bevelStyle", beanClass);
  334.         bevelStyle.setBound(true);
  335.         bevelStyle.setConstrained(true);
  336.         bevelStyle.setDisplayName(prop.getString("bevelStyle"));
  337.         bevelStyle.setValue("ENUMERATION", "BEVEL_LOWERED=0, BEVEL_RAISED=1, BEVEL_LINE=2, BEVEL_NONE=3");
  338.  
  339.         PropertyDescriptor borderIndent = new PropertyDescriptor("borderIndent", beanClass);
  340.         borderIndent.setBound(true);
  341.         borderIndent.setConstrained(true);
  342.         borderIndent.setDisplayName(prop.getString("borderIndent"));
  343.         borderIndent.setValue("ENUMERATION", "INDENT_ZERO, INDENT_ONE, INDENT_TWO");
  344.  
  345.         PropertyDescriptor borderedColor = new PropertyDescriptor("borderedColor", beanClass);
  346.         borderedColor.setBound(true);
  347.         borderedColor.setConstrained(true);
  348.         borderedColor.setDisplayName(prop.getString("borderedColor"));
  349.  
  350.         PropertyDescriptor textColor = new PropertyDescriptor("textColor", beanClass);
  351.         textColor.setBound(true);
  352.         textColor.setConstrained(true);
  353.         textColor.setDisplayName(prop.getString("textColor"));
  354.  
  355.         PropertyDescriptor[] rv = {
  356.             defProperty,
  357.             alignStyle,
  358.             bevelStyle,
  359.             borderIndent,
  360.             borderedColor,
  361.             textColor};
  362.         return rv;
  363.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  364.     }
  365.  
  366.     /**
  367.      * Returns the index of the property expected to be changed most often by the designer.
  368.      */
  369.     public int getDefaultPropertyIndex() {
  370.         return 0;    //  the index for our default property is always 0
  371.     }
  372.  
  373.     private final static Class beanClass = Label3D.class;
  374.  
  375.     }    //  end of class Label3DBeanInfo